﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Xml;
using System.Web;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search;
using System.Linq;
using DotNetNuke.Services.Exceptions;

namespace DNNToolkit.Modules.Glossary.Components
{
    public class GlossaryController
    /*// : DotNetNuke.Entities.Modules.ISearchable, DotNetNuke.Entities.Modules.IPortable*/
    {
        private readonly DataManager manager = new DataManager();

        #region "Public Methods"
        // Get a single Glossary item by primary key

        public GlossaryInfo GetGlossary(long glossaryID)
        {
            return manager.GetGlossary(glossaryID);
        }

        //List all Glossary items
        public IQueryable<GlossaryInfo> ListGlossary(int moduleID)
        {
            return manager.ListGlossary(moduleID);
        }

        //List glossaries by filter 
        public IQueryable<GlossaryInfo> ListGlossaryByFilter(int moduleID, string filter)
        {
            return manager.ListGlossaryByFilter(moduleID, filter);
        }

        //List golssaries by filter and category
        public IQueryable<GlossaryInfo> ListGlossaryByFilterAndCategory(int moduleID, string filter, long glossaryCategoryDefinitionID)
        {
            return manager.ListGlossaryByFilterAndCategory(moduleID, filter, glossaryCategoryDefinitionID);
        }

        //List glossaries by category
        public IQueryable<GlossaryInfo> ListGlossaryByCategory(int moduleID, long glossaryCategoryDefinitionID)
        {
            return manager.ListGlossaryByCategory(moduleID, glossaryCategoryDefinitionID);
        }

        //List gossaries by letter
        public IQueryable<GlossaryInfo> ListGlossaryByLetter(int moduleID, string letter)
        {
            return manager.ListGlossaryByLetter(moduleID, letter);
        }


        public void CreateGlossary(GlossaryInfo objGlossary)
        {
            manager.CreateGlossary(objGlossary);
        }

        public void UpdateGlossary(GlossaryInfo objGlossary)
        {
            manager.UpdateGlossary(objGlossary.GlossaryID, objGlossary.Term, objGlossary.Definition, objGlossary.ModuleID, objGlossary.DateTimeStamp);
        }

        public void DeleteGlossary(GlossaryInfo objGlossary)
        {
            manager.DeleteGlossary(objGlossary.GlossaryID);
        }

        // Get a single GlossaryCategory item by primary key
        public GlossaryCategory GetGlossaryCategory(long glossaryCategoryID)
        {
            return manager.GetGlossaryCategory(glossaryCategoryID);
        }

        public IQueryable<GlossaryCategory> ListGlossaryCategory()
        {
            return manager.ListGlossaryCategory();
        }

        public IQueryable<GlossaryCategory> GetByGlossary(long glossaryID)
        {
            return manager.GetGlossaryCategoryByGlossary(glossaryID);
        }
        public IQueryable<GlossaryCategory> GetByGlossaryCategoryDefinition(long glossaryCategoryDefinitionID)
        {
            return manager.GetGlossaryCategoryByGlossaryCategoryDefinition(glossaryCategoryDefinitionID);
        }

        public void CreateGlossaryCategory(GlossaryCategory objGlossaryCategory)
        {
            manager.CreateGlossaryCategory(objGlossaryCategory);
        }

        public void UpdateGlossaryCategory(GlossaryCategory objGlossaryCategory)
        {
            manager.UpdateGlossaryCategory(objGlossaryCategory.GlossaryCategoryID, objGlossaryCategory.GlossaryID, objGlossaryCategory.GlossaryCategoryDefinitionID);
        }

        public void DeleteGlossaryCategory(long glossaryCategoryID)
        {
            manager.DeleteGlossaryCategory(glossaryCategoryID);
        }

        public void DeleteGlossaryCategoryByGlossary(long glossaryID)
        {
            manager.DeleteGlossaryCategoryByGlossary(glossaryID);
        }

        // Get a single GlossaryCategoryDefinition item by primary key
        public GlossaryCategoryDefinition GetGlossaryCategoryDefinition(long glossaryCategoryDefinitionID)
        {
            return manager.GetGlossaryCategoryDefinition(glossaryCategoryDefinitionID);
        }

        public IQueryable<GlossaryCategoryDefinition> ListGlossaryCategoryDefinition()
        {
            return manager.ListGlossaryCategoryDefinition();
        }


        public void CreateGlossaryCategoryDefinition(GlossaryCategoryDefinition objGlossaryCategoryDefinition)
        {
            manager.CreateGlossaryCategoryDefinition(objGlossaryCategoryDefinition);
        }

        public void UpdateGlossaryCategoryDefinition(GlossaryCategoryDefinition objGlossaryCategoryDefinition)
        {
            manager.UpdateGlossaryCategoryDefinition(objGlossaryCategoryDefinition.GlossaryCategoryDefinitionID, objGlossaryCategoryDefinition.CategoryName);
        }

        public void DeleteGlossaryCategoryDefinition(GlossaryCategoryDefinition objGlossaryCategoryDefinition)
        {
            manager.DeleteGlossaryCategoryDefinition(objGlossaryCategoryDefinition.GlossaryCategoryDefinitionID);
        }


        #endregion
    }

}